﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfCodes.Test
{
    /// <summary>
    /// Interaction logic for ImageTest.xaml
    /// </summary>
    public partial class ImageTest : Window
    {
        public ImageTest()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(ImageTest_Loaded);
        }

        void ImageTest_Loaded(object sender, RoutedEventArgs e)
        {
            string strPath = @"\Images\";
            StringBuilder sb = new StringBuilder();
            sb.Append(System.AppDomain.CurrentDomain.BaseDirectory.Replace(@"\bin\Debug\", ""));
            sb.Append(strPath);
            sb.Append("Lighthouse.jpg");
            
            //  Method 1
            //Image1.Source = new BitmapImage(new Uri(@"pack://application:,,,/Images/Hydrangeas.jpg"));
            //Image1.Source = new BitmapImage(new Uri(@"E:\Files\works\MyCodeShop\WPFCodes\WpfCodes\WpfCodes\Images\Lighthouse.jpg", UriKind.Absolute));
            //Image1.Source = new BitmapImage(new Uri(sb.ToString()));

            //  Method 2
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri("/Images/Hydrangeas.jpg", UriKind.Relative);
            bi.EndInit();
            Image1.Source = bi;

            //  Method 3
            //ImageSourceConverter isc = new ImageSourceConverter();
            //Image1.Source = (ImageSource)isc.ConvertFromString(@"pack://application:,,,/WpfCodes;component/test/Images/Hydrangeas.jpg");
            //Image1.Source = (ImageSource)isc.ConvertFromString(@"pack://application:,,,/Images/Hydrangeas.jpg");
        }


    }
}
